package fi.uba.algocontrol.view.factory;


import fi.uba.algocontrol.controller.AvionController;
import fi.uba.algocontrol.model.aviones.AvionFactory;
import fi.uba.algocontrol.view.AvionView;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

public class AvionViewFactory
{
    AvionController avionController;
    public AvionViewFactory(AvionController avionController)
    {
        this.avionController = avionController;
    }

    public AvionView crearAvion() throws MalformedURLException,IOException
    {
        if (Math.random()*10 < 5)
            return this.crearAvionSimple();

        if (Math.random()*10 < 2)
            return this.crearAvionHelicoptero();

        return this.crearAvionPesado();
    }

    private AvionView crearAvionSimple() throws MalformedURLException,IOException
    {
        return  new AvionView(new URL("file", "", "resources/images/avion-simple.png"), AvionFactory.getInstance().crearAvionSimple(), this.avionController);
    }

    private AvionView crearAvionPesado() throws MalformedURLException,IOException
    {
        return  new AvionView(new URL("file", "", "resources/images/avion-pesado.png"), AvionFactory.getInstance().crearAvionPesado(), this.avionController);
    }
    
    private AvionView crearAvionHelicoptero() throws MalformedURLException,IOException
    {
        return  new AvionView(new URL("file", "", "resources/images/avion-helicoptero.png"), AvionFactory.getInstance().crearAvionHelicoptero(), this.avionController);
    }
}
